package StudyCode.summary.mycollection;

import java.util.LinkedHashSet;
import java.util.Set;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class CopiesEntriesFromTheSetProvidedUntilReachingABarrierItem {
	static Set<String> copyUntil(final Set<String> source,
	                             final String barrier) {
		final Set<String> subset = new LinkedHashSet<String>();
		for (final String sourceItem : source) {
			if (barrier.equals(sourceItem)) {
				break;
			}
			subset.add(sourceItem);
		}
		return subset;
	}
}
